﻿Imports BUS

Public Class frmChonNgay

    Private frmcho As DevExpress.Utils.WaitDialogForm

    Private Sub EnableControl(ByVal b As Boolean)
        dttungay.Enabled = b
        dtdengay.Enabled = b
        lbtungay.Enabled = b
        lbdenngay.Enabled = b
    End Sub

    Private Sub frmChonNgay_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As New DataTable
        dt = BoPhanBus.LayDanhSach()
        cbobophan.DataSource = dt
        cbobophan.DisplayMember = "tenbp"
        cbobophan.ValueMember = "mabp"

        EnableControl(False)
    End Sub

    Private Sub chkngay_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkngay.CheckedChanged
        EnableControl(chkngay.Checked)
    End Sub

    Private Sub btndongy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndongy.Click
        frmcho = New DevExpress.Utils.WaitDialogForm("Vui lòng chờ", "Đang xử lý")
        Dim rpt As New rptDanhSachNhanVien
        rpt.xrlTieuDe.Text = "DANH SÁCH NHÂN VIÊN"
        Dim sql As String = ""
        If (chkngay.Checked = False) Then
            sql = "exec sp_laydanhsachnhanvien " & cbobophan.SelectedValue & ", 0, '2013-1-1', '2013-1-1'"
        Else
            sql = "exec sp_laydanhsachnhanvien " & cbobophan.SelectedValue & ", 1, '" & String.Format("{0:yyyy-MM-dd}", dttungay.Value) & "', '" & String.Format("{0:yyyy-MM-dd}", dtdengay.Value) & "'"
        End If
        rpt.DataSource = ProcFuncBus.ExecuteFuncSQL(sql)
        rpt.CreateDocument()
        rpt.ShowPreview()
        frmcho.Close()
    End Sub
End Class